<?php

namespace Drupal\shusy_store_order_line\MetadataController;

use EntityDefaultMetadataController;

class ShusyStoreOrderLineMetadataController extends EntityDefaultMetadataController {

  public static function bundleOptionsList($name, $info) {
    return parent::bundleOptionsList($name, $info);
  }

  public function entityPropertyInfo() {
    $info = parent::entityPropertyInfo();
    $properties = &$info[$this->type]['properties'];
    $properties['user'] = [
      'label' => t('所有人'),
      'type' => 'user',
      'schema field' => 'uid',
      'description' => t('所有人.'),
    ];
    $properties['op_user'] = [
      'label' => t('操作人'),
      'type' => 'user',
      'schema field' => 'op_uid',
      'description' => t('操作人.'),
    ];

    $properties['created'] = [
      'label' => t('记录时间'),
      'type' => 'date',
      'schema field' => 'created',
      'description' => t('记录时间.'),
    ];
    $properties['changed'] = [
      'label' => t('变化时间'),
      'type' => 'date',
      'schema field' => 'changed',
      'description' => t('变化时间.'),
    ];

    $properties['order'] = [
      'label' => t('订单'),
      'type' => 'shusy_store_order',
      'schema field' => 'store_order_id',
      'description' => t('订单.'),
    ];


    $properties['type'] = [
      'label' => t('Type'),
      'description' => t('The human readable name of the line item type.'),
      'type' => 'token',
      'setter callback' => 'entity_property_verbatim_set',
      'options list' => 'shusy_store_order_line_type_options_list',
      'required' => TRUE,
      'schema field' => 'type',
    ];
    $bundles =  &$info[$this->type]['bundles'];
    $bundles = [];
    $types = shusy_store_order_line_type_options_list();
    foreach ($types as $type => $name) {
      $bundles[$type] = ['label' => $name,];
    }
    return $info;
  }

}
